using Circus.CodeEditor;
using Circus.CodeEditor.Serialization;
using Circus.CodeEditor.TextSource;
using Circus.Syntax;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace Circus.CodeEditor
{
	public class Gutter :  IDisposable
	{
		public class BookmarkComparer : IComparer<Gutter.BookMarkImage>
		{
			public int Compare(Gutter.BookMarkImage x, Gutter.BookMarkImage y)
			{
				int num = x.ZIndex - y.ZIndex;
				int result;
				if (num != 0)
				{
					result = num;
				}
				else
				{
					if (x.ImageIndex > y.ImageIndex)
					{
						result = -1;
					}
					else
					{
						result = ((x.ImageIndex < y.ImageIndex) ? 1 : 0);
					}
				}
				return result;
			}
		}
		public class BookMarkImage
		{
			public ImageList Images;
			public int Index;
			public int ImageIndex;
			public int Group;
			public int ZIndex;
			public BookMarkImage(ImageList images, int group, int index, int imageIndex, int zIndex)
			{
				this.Images = images;
				this.Group = group;
				this.ZIndex = zIndex;
				this.ImageIndex = imageIndex;
				this.Index = index;
			}
		}
		private CodeEditor owner;
		private int updateCount;
		private Brush brush;
		private Pen pen;
		private bool visible = true;
		private int width = EditConsts.DefaultGutterWidth;
		private GutterOptions options;
		private ImageList images;
		private ImageList internalImages;
		private List<Range> ranges;
		private int lineNumberWidth;
		private int lineNumberLength;
		private StringAlignment lineNumbersAlignment = StringAlignment.Near;
		private int lineNumbersStart = EditConsts.DefaultLineNumbersStart;
		private int lineNumbersLeftIndent = EditConsts.DefaultLineNumbersIndent;
		private int lineNumbersRightIndent = EditConsts.DefaultLineNumbersIndent;
		private int outliningLeftIndent = EditConsts.DefaultOutliningIndent;
		private int outliningRightIndent = EditConsts.DefaultOutliningIndent;
		private int bookMarkImageIndex = EditConsts.DefaultBookMarkImageIndex;
		private int wrapImageIndex = EditConsts.DefaultWrapImageIndex;
		private Color lineModificatorChangedColor;
		private Color lineModificatorSavedColor;
		private Color outlineImageBackColor;
		private Color highlightOutlineAreaColor;
		private Color lineNumbersForeColor;
		private Color lineNumbersBackColor;
		private bool drawLineBookmarks;
		private bool showBookmarkHints = true;
		private Color lineBookmarksColor = EditConsts.DefaultLineBookmarksColor;
	
		private IComparer<Gutter.BookMarkImage> bookmarkComparer = new Gutter.BookmarkComparer();

	    [Browsable(false)]
	    public event EventHandler Click;

	    [Browsable(false)]
	    public event EventHandler DoubleClick;
	
		protected bool Transparent
		{
			get
			{
				return this.owner != null && this.owner.Transparent;
			}
		}
	
		[Description("Gets or sets the width of the gutter.")]
		public virtual int Width
		{
			get
			{
				return this.width;
			}
			set
			{
				if (this.width != value)
				{
					this.width = value;
					this.OnWidthChanged();
				}
			}
		}
		
		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public virtual Pen Pen
		{
			get
			{
				return this.pen;
			}
			set
			{
				if (this.pen != value)
				{
					this.pen = value;
				    this.Update();
				}
			}
		}
		[Description("Gets or sets background color of the gutter.")]
		public virtual Color BrushColor
		{
			get
			{
				return (this.brush is SolidBrush) ? ((SolidBrush)this.brush).Color : EditConsts.DefaultGutterBackColor;
			}
			set
			{
				if (this.brush is SolidBrush && ((SolidBrush)this.brush).Color != value)
				{
					((SolidBrush)this.brush).Color = value;
				    this.Update();
				}
			}
		}
		[Description("Gets or sets color of the gutter line.")]
		public virtual Color PenColor
		{
			get
			{
				return this.pen.Color;
			}
			set
			{
				if (this.pen.Color != value)
				{
					this.pen.Color = value;
				    this.Update();
				}
			}
		}
		[DefaultValue(true), Description("Gets or sets a value indicating whether the gutter area is visible.")]
		public virtual bool Visible
		{
			get
			{
				return this.visible;
			}
			set
			{
				if (this.visible != value)
				{
					this.visible = value;
					this.OnVisibleChanged();
				}
			}
		}
		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public virtual Rectangle Rect
		{
			get
			{
				Rectangle result = (this.owner != null) ? this.owner.ClientArea : new Rectangle(0, 0, 0, 0);
				result.Width = this.DisplayWidth;
				return result;
			}
		}
		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public virtual int DisplayWidth
		{
			get
			{
				return this.GetDisplayWidth(false);
			}
		}
		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public virtual int DisplayArea
		{
			get
			{
				return this.GetDisplayWidth(true);
			}
		}
		[Description("Gets or sets number of the first line being painted on the gutter.")]
		public virtual int LineNumbersStart
		{
			get
			{
				return this.lineNumbersStart;
			}
			set
			{
				if (this.lineNumbersStart != value)
				{
					this.lineNumbersStart = value;
				    this.InvalidateLineNumberArea(true);
				    this.Update();
				}
			}
		}
		[Description("Gets or sets line numbers indentation from the left gutter border.")]
		public virtual int LineNumbersLeftIndent
		{
			get
			{
				return this.lineNumbersLeftIndent;
			}
			set
			{
				if (this.lineNumbersLeftIndent != value)
				{
					this.lineNumbersLeftIndent = value;
				    this.InvalidateLineNumberArea(true);
				    this.Update();
				}
			}
		}
		[Description("Gets or sets line numbers indentation from the right gutter border.")]
		public virtual int LineNumbersRightIndent
		{
			get
			{
				return this.lineNumbersRightIndent;
			}
			set
			{
				if (this.lineNumbersRightIndent != value)
				{
					this.lineNumbersRightIndent = value;
					this.OnLineNumbersRightIndentChanged();
				}
			}
		}
		[Description("Gets or sets foreground color for the line numbers.")]
		public virtual Color LineNumbersForeColor
		{
			get
			{
				return this.lineNumbersForeColor;
			}
			set
			{
				if (this.lineNumbersForeColor != value)
				{
					this.lineNumbersForeColor = value;
					this.OnLineNumbersForeColorChanged();
				}
			}
		}
		[Description("Gets or sets background color for the line numbers.")]
		public virtual Color LineNumbersBackColor
		{
			get
			{
				return this.lineNumbersBackColor;
			}
			set
			{
				if (this.lineNumbersBackColor != value)
				{
					this.lineNumbersBackColor = value;
					this.OnLineNumbersBackColorChanged();
				}
			}
		}
		[Description("Gets or sets a \"GutterOptions\" that determine gutter appearance and behaviour."), Editor("QWhale.Design.FlagEnumerationEditor, QWhale.Design", typeof(UITypeEditor))]
		public virtual GutterOptions Options
		{
			get
			{
				return this.options;
			}
			set
			{
				if (this.options != value)
				{
					this.options = value;
				    this.InvalidateLineNumberArea(true);
				    this.Update();
				}
			}
		}
		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public virtual ImageList Images
		{
			get
			{
				return (this.images != null) ? this.images : this.internalImages;
			}
			set
			{
				if (this.images != value)
				{
					this.images = value;
				    this.Update();
				}
			}
		}
		[Description("Gets or sets a value that specifies index of item in the image collection used to paint bookmark.")]
		public virtual int BookMarkImageIndex
		{
			get
			{
				return this.bookMarkImageIndex;
			}
			set
			{
				if (this.bookMarkImageIndex != value)
				{
					this.bookMarkImageIndex = value;
				    this.Update();
				}
			}
		}
		[Description("Gets or sets a value that specifies index of item in the image collection used to paint special mark indicating the wrapped line.")]
		public virtual int WrapImageIndex
		{
			get
			{
				return this.wrapImageIndex;
			}
			set
			{
				if (this.wrapImageIndex != value)
				{
					this.wrapImageIndex = value;
				    this.Update();
				}
			}
		}
		[DefaultValue(false), Description("Gets or sets a value indicating whether Edit control should draw triangle at bookmark position inside line.")]
		public virtual bool DrawLineBookmarks
		{
			get
			{
				return this.drawLineBookmarks;
			}
			set
			{
				if (this.drawLineBookmarks != value)
				{
					this.drawLineBookmarks = value;
					this.OnDrawLineBookmarksChanged();
				}
			}
		}
		[Description("Gets or sets a color of the line bookmarks.")]
		public virtual Color LineBookmarksColor
		{
			get
			{
				return this.lineBookmarksColor;
			}
			set
			{
				if (this.lineBookmarksColor != value)
				{
					this.lineBookmarksColor = value;
					this.OnLineBookmarksColorChanged();
				}
			}
		}
		[DefaultValue(true), Description("Gets or sets a value indicating whether Edit control should display text describing bookmark in form of tooltip window when mouse pointer is over the gutter bookmark.")]
		public virtual bool ShowBookmarkHints
		{
			get
			{
				return this.showBookmarkHints;
			}
			set
			{
				if (this.showBookmarkHints != value)
				{
					this.showBookmarkHints = value;
					this.OnShowBookmarkHintsChanged();
				}
			}
		}
		[Description("Gets or sets a color of the line modificators(color stitch that indicates that the line content is unmodified, modified or saved) in the modified state.")]
		public virtual Color LineModificatorChangedColor
		{
			get
			{
				return this.lineModificatorChangedColor;
			}
			set
			{
				if (this.lineModificatorChangedColor != value)
				{
					this.lineModificatorChangedColor = value;
				    this.Update((this.options & GutterOptions.PaintLineModificators) != GutterOptions.None);
				}
			}
		}
		[Description("Gets or sets a color of the line modificators(color stitch that indicates that the line content is unmodified, modified or saved) in the saved state.")]
		public virtual Color LineModificatorSavedColor
		{
			get
			{
				return this.lineModificatorSavedColor;
			}
			set
			{
				if (this.lineModificatorSavedColor != value)
				{
					this.lineModificatorSavedColor = value;
				    this.Update((this.options & GutterOptions.PaintLineModificators) != GutterOptions.None);
				}
			}
		}
		[Description("Gets or sets an outline image back color.")]
		public virtual Color OutlineImageBackColor
		{
			get
			{
				return this.outlineImageBackColor;
			}
			set
			{
				if (this.outlineImageBackColor != value)
				{
					this.outlineImageBackColor = value;
				}
			}
		}
		[Description("Gets or sets a background color of the highlighted outline area.")]
		public virtual Color HighlightOutlineAreaColor
		{
			get
			{
				return this.highlightOutlineAreaColor;
			}
			set
			{
				if (this.highlightOutlineAreaColor != value)
				{
					this.highlightOutlineAreaColor = value;
				}
			}
		}
	
		public Gutter()
		{
			this.brush = new SolidBrush(EditConsts.DefaultGutterBackColor);
			this.pen = new Pen(EditConsts.DefaultGutterForeColor, 1f);
			this.internalImages = new ImageList();
			this.internalImages.ImageSize = new Size(15, 15);
			this.ranges = new List<Range>();
			this.options = EditConsts.DefaultGutterOptions;
			this.lineNumbersForeColor = EditConsts.DefaultLineNumbersForeColor;
			this.lineNumbersBackColor = EditConsts.DefaultLineNumbersBackColor;
			this.lineModificatorChangedColor = EditConsts.DefaultLineModificatorChangedColor;
			this.lineModificatorSavedColor = EditConsts.DefaultLineModificatorSavedColor;
			this.outlineImageBackColor = EditConsts.DefaultOutlineImageBackColor;
			this.highlightOutlineAreaColor = EditConsts.DefaultHighlightOutlineAreaColor;
			
			try
			{
                //ResourceManager resourceManager = new ResourceManager(typeof(Resources));
                //this.internalImages.ImageStream = (ImageListStreamer)resourceManager.GetObject("SyntaxEdit.Gutter.Images.ImageStream");
			}
			catch
			{
			}
			this.internalImages.TransparentColor = EditConsts.DefaultTransparentColor;
		}
		public Gutter(CodeEditor owner) : this()
		{
			this.owner = owner;
		}
		~Gutter()
		{
			this.Dispose(false);
		}
	
		public void Update(bool needChange)
		{
			if (this.updateCount == 0 && this.owner != null && needChange)
			{
				this.owner.UpdateCaret();
				this.owner.Invalidate();
			}
		}
		public void Update()
		{
			this.Update(true);
		}
		private int GetLineNumbersWidth()
		{
			int result;
			if ((this.options & GutterOptions.PaintLineNumbers) == GutterOptions.None)
			{
				result = 0;
			}
			else
			{
				result = this.lineNumberWidth;
			}
			return result;
		}
		private bool NeedPaint(ref Rectangle rect)
		{
			bool result;
			if (this.owner != null)
			{
				if (!rect.IsEmpty)
				{
					int lineHeight = this.owner.Painter.lineHeight;
					if (lineHeight > 0)
					{
						int bottom = rect.Bottom;
						rect.Y = rect.Top / lineHeight * lineHeight;
						rect.Height = bottom - rect.Y;
					}
					result = true;
					return result;
				}
			}
			result = false;
			return result;
		}
		private void CenterOutlineRect(ref int l, ref int t, int w)
		{
			int num = this.ImageWidth();
			int num2 = w - num >> 1;
			if (num2 > 0)
			{
				l += num2;
				t += num2;
			}
		}
		private void DrawLine(Painter painter, int x1, int y1, int x2, int y2)
		{
			painter.DrawLine(x1, y1, x2, y2);
			if (!this.Transparent)
			{
				if (x1 == x2)
				{
					painter.ExcludeClipRect(x1, y1, 1, y2 - y1);
				}
				else
				{
					painter.ExcludeClipRect(x1, y1, x2 - x1, 1);
				}
			}
		}
		private void DrawRectangle(Painter painter, Rectangle rect, bool drawPlus)
		{
			Rectangle rect2 = new Rectangle(rect.Left + 1, rect.Top + 1, rect.Width - 1, rect.Height - 1);
			if (!this.Transparent)
			{
				Color backColor = painter.BackColor;
				try
				{
					painter.BackColor = ((this.visible && (this.owner.Outlining.OutlineOptions & OutlineOptions.DrawOnGutter) != OutlineOptions.None) ? this.BrushColor : (drawPlus ? this.outlineImageBackColor : this.owner.SyntaxPaint.GetBackColor(false)));
					painter.FillRectangle(rect2);
				}
				finally
				{
					painter.BackColor = backColor;
				}
			}
			int num = this.ImageWidth();
			painter.DrawRectangle(rect.Left, rect.Top, rect.Width, rect.Height);
			painter.DrawLine(rect.Left + 2, rect.Top + (num >> 1), rect.Left + num - 1, rect.Top + (num >> 1));
			if (drawPlus)
			{
				painter.DrawLine(rect.Left + (num >> 1), rect.Top + 2, rect.Left + (num >> 1), rect.Top + num - 1);
			}
			if (!this.Transparent)
			{
				painter.ExcludeClipRect(rect.Left, rect.Top, rect.Width + 1, rect.Height + 1);
			}
		}
		private void DrawOutline(Painter painter, int line, int l, int t, int w, bool end)
		{
			int num = this.ImageWidth();
			int num2 = t;
			this.CenterOutlineRect(ref l, ref t, w);
			Rectangle rect = new Rectangle(l, t, num, w);
			Color foreColor = painter.ForeColor;
			try
			{
				painter.ForeColor = this.owner.Outlining.OutlineColor;
				
				{
					if (end)
					{
						this.DrawLine(painter, l + (num >> 1), num2, l + (num >> 1), num2 + w - 1);
						this.DrawLine(painter, l + (num >> 1), num2 + w - 1, l + num + 2, num2 + w - 1);
					}
					else
					{
						this.DrawLine(painter, l + (num >> 1), num2, l + (num >> 1), num2 + w + 1);
					}
				}
			}
			finally
			{
				painter.ForeColor = foreColor;
			}
		}
		private int ImageWidth()
		{
			return (this.owner != null) ? this.owner.Outlining.ImageSize : EditConsts.DefaultCollasedImageWidth;
		}
		private void DrawOutlineImage(Painter painter, int line, int l, int t, int w, bool drawLines, bool visible, bool before, bool after)
		{
			int num = this.ImageWidth();
			int num2 = t;
			this.CenterOutlineRect(ref l, ref t, w);
			Rectangle rect = new Rectangle(l, t, num, num);
			Outlining outlining = this.owner.Outlining;
			Color backColor = painter.BackColor;
			Color foreColor = painter.ForeColor;
			try {
			    painter.BackColor = outlining.OutlineColor;
			    painter.ForeColor = outlining.OutlineColor;
			    this.DrawRectangle(painter, rect, !visible);
			    if (drawLines) {
			        if (before) {
			            this.DrawLine(painter, l + (num >> 1), num2, l + (num >> 1), t + 1);
			        }
			        if (after) {
			            this.DrawLine(painter, l + (num >> 1), t + num, l + (num >> 1), num2 + w + 1);
			        }
			    }
			} finally
			{
				painter.BackColor = backColor;
				painter.ForeColor = foreColor;
			}
		}
		private int CompareRange(Point pt, Point sPt, Point ePt)
		{
			int result;
			if (pt.Y < sPt.Y || (pt.Y == sPt.Y && pt.X < sPt.X))
			{
				result = 1;
			}
			else
			{
				if (pt.Y > ePt.Y || (pt.Y == ePt.Y && pt.X >= ePt.X && ePt.X != int.MaxValue))
				{
					result = -1;
				}
				else
				{
					result = 0;
				}
			}
			return result;
		}
		private void DrawLineNumber(Painter painter, int line, int left, int top, bool drawOnGutter)
		{
			if (this.owner != null)
			{
				bool flag = true;
				Rectangle rect = new Rectangle(left, top, this.lineNumberWidth - (this.LineNumbersLeftIndent + this.LineNumbersRightIndent + (flag ? 1 : 0)), painter.lineHeight);
				Color textColor = painter.TextColor;
				Color backColor = painter.BackColor;
				bool transparent = this.Transparent;
				try
				{
					painter.TextColor = this.lineNumbersForeColor;
					painter.BackColor = (drawOnGutter ? this.BrushColor : this.lineNumbersBackColor);
					if (transparent)
					{
						painter.Opaque = false;
					}
					var text = (line + this.lineNumbersStart).ToString();
					
					{
						switch (this.lineNumbersAlignment)
						{
						case StringAlignment.Near:
                                painter.TextOut(text, -1, rect, false, !transparent);
							break;
						case StringAlignment.Center:
						{
                            int num = painter.measureString(text);
                            painter.TextOut(text, -1, rect, rect.Left + (rect.Width - num) / 2, rect.Top, false, !transparent);
							break;
						}
						case StringAlignment.Far:
						{
                            int num = painter.measureString(text);
                            painter.TextOut(text, -1, rect, rect.Left + rect.Width - num, rect.Top, false, !transparent);
							break;
						}
						}
					}
					
				}
				finally
				{
					if (transparent)
					{
						painter.Opaque = true;
					}
					painter.TextColor = textColor;
					painter.BackColor = backColor;
				}
			}
		}
	
	
		private void DrawLineModificator(Painter painter, int line, int left, int top)
		{
			if (this.owner != null)
			{
				Rectangle rect = new Rectangle(left, top, this.GetLineModificatorWidth(false), painter.lineHeight);
				Color backColor = painter.BackColor;
				try
				{
					bool flag2;
					bool flag = this.owner.Source.LineIsModified(line, out flag2);
					if (flag)
					{
						painter.BackColor = (flag2 ? this.LineModificatorSavedColor : this.LineModificatorChangedColor);
					}
				 
						if (flag)
						{
							painter.FillRectangle(rect);
							painter.ExcludeClipRect(rect.Left, rect.Top, rect.Width, rect.Height);
						}
				  
				}
				finally
				{
					painter.BackColor = backColor;
				}
			}
		}
		private bool NeedLineNumbers()
		{
			return (this.options & GutterOptions.PaintLineNumbers) != GutterOptions.None;
		}
		private int GetLineNumbersLeft(bool useIndent)
		{
			return this.NeedLineNumbers() ? (((this.visible && (this.options & GutterOptions.PaintLinesOnGutter) == GutterOptions.None) ? this.GetPaintWidth() : 0) + (useIndent ? this.lineNumbersLeftIndent : 0)) : 0;
		}
		private int GetLineNumbersRight(bool useIndent)
		{
			bool flag = (this.options & GutterOptions.PaintLineNumbers) != GutterOptions.None && ((this.options & GutterOptions.PaintLinesOnGutter) == GutterOptions.None || !this.Visible);
			return this.NeedLineNumbers() ? (this.GetLineNumbersLeft(useIndent) + this.lineNumberWidth - (useIndent ? (this.LineNumbersRightIndent + this.lineNumbersLeftIndent + (flag ? 1 : 0)) : 0)) : 0;
		}
		private int GetOutlineLeft(bool useIndent)
		{
			int result;
			if (this.owner != null && (this.owner.Outlining.OutlineOptions & OutlineOptions.DrawOnGutter) != OutlineOptions.None && this.Visible)
			{
				result = this.GetPaintWidth() - 0 - this.GetOutlineWidth() + (useIndent ? this.outliningLeftIndent : 0);
			}
			else
			{
				result = this.DisplayWidth - this.GetOutlineWidth() + (useIndent ? this.outliningLeftIndent : 0);
			}
			return result;
		}
		private int GetOutlineWidth()
		{
			return this.AllowOutlining() ? (this.owner.Painter.lineHeight + this.outliningLeftIndent + this.outliningRightIndent) : 0;
		}

	    private int GetLineModificatorWidth(bool checkOutlining)
		{
			return this.GetLineModificatorWidth(checkOutlining, false);
		}
		private int GetLineModificatorWidth(bool checkOutlining, bool charWidth)
		{
			int num = ((this.options & GutterOptions.PaintLineModificators) != GutterOptions.None) ? EditConsts.DefaultLineModificatorWidth : 0;
			if (!charWidth && num != 0 && checkOutlining && this.AllowOutlining() && this.owner != null && (!this.Visible || (this.owner.Outlining.OutlineOptions & OutlineOptions.DrawOnGutter) == OutlineOptions.None))
			{
				num = 0;
			}
			return num;
		}
		private int GetLineModificatorLeft()
		{
			return this.DisplayWidth - ((this.AllowOutlining() && this.owner != null && (!this.Visible || (this.owner.Outlining.OutlineOptions & OutlineOptions.DrawOnGutter) == OutlineOptions.None)) ? this.GetOutlineWidth() : this.GetLineModificatorWidth(false));
		}
		private int GetPaintWidth()
		{
			return this.GetPaintWidth(true);
		}
		private int GetPaintWidth(bool CheckOutlining)
		{
			int num = this.visible ? this.Width : 0;
			if ((this.options & GutterOptions.PaintLinesOnGutter) != GutterOptions.None)
			{
				num = Math.Max(num, this.GetLineNumbersWidth());
			}
			num += 0;
			num += (this.visible ? ((int)this.Pen.Width + EditConsts.DefaultGutterOffset) : ((int)this.Pen.Width));
			if (CheckOutlining && this.owner != null && (this.owner.Outlining.OutlineOptions & OutlineOptions.DrawOnGutter) != OutlineOptions.None)
			{
				num += this.GetOutlineWidth();
			}
			return num;
		}
		protected virtual int GetDisplayWidth(bool charWidth)
		{
			int num = this.visible ? this.Width : 0;
			int lineNumbersWidth = this.GetLineNumbersWidth();
			if ((this.options & GutterOptions.PaintLinesOnGutter) == GutterOptions.None)
			{
				num += lineNumbersWidth;
			}
			else
			{
				num = Math.Max(num, lineNumbersWidth);
			}
			num += (int)this.Pen.Width;
			return num + this.GetLineModificatorWidth(true, charWidth) + this.GetOutlineWidth() + 0 + (this.visible ? EditConsts.DefaultGutterOffset : 0);
		}
		private void DrawImage(Painter painter, ImageList images, int imageIndex, int line, int left, int top, int right, bool bookmark)
		{
			if (this.CanDrawImage(images, imageIndex, left, right)) {
			    Rectangle rect = new Rectangle(left, top, images.ImageSize.Width, images.ImageSize.Height);
			    painter.DrawImage(images, imageIndex, rect);
			}
		}
		private bool UpdateLineNumberLength(bool updateWidth)
		{
			bool flag = false;
			if (this.owner != null && this.owner.DisplayLines != null)
			{
				int val = Math.Max(Math.Max(this.owner.DisplayLines.DisplayCount, this.owner.Lines.Count) + this.lineNumbersStart - 1, 0);
				if ((this.options & GutterOptions.PaintLinesBeyondEof) != GutterOptions.None)
				{
					int num;
					{
						num = this.owner.Scrolling.WindowOriginY;
						int lineHeight = this.owner.Painter.lineHeight;
						if (lineHeight != 0)
						{
							int clientHeight = this.owner.ClientHeight;
							num += clientHeight / lineHeight + ((clientHeight % lineHeight != 0) ? 1 : 0);
						}
					}
					var source = this.owner.Source;
					NavigateOptions navigateOptions = source.NavigateOptions;
					try
					{
						source.SetNavigateOptions(navigateOptions | NavigateOptions.BeyondEof);
						num = this.owner.DisplayLines.DisplayPointToPoint(0, num).Y;
					}
					finally
					{
						source.SetNavigateOptions(navigateOptions);
					}
					val = Math.Max(val, num);
				}
				int num2 =val.ToString().Length;
				flag = (this.lineNumberLength != num2);
				this.lineNumberLength = num2;
				if (flag || updateWidth)
				{
				    this.owner.Painter.fontStyle = this.owner.Font.Style;
				    bool flag2 = (this.options & GutterOptions.PaintLineNumbers) != GutterOptions.None && ((this.options & GutterOptions.PaintLinesOnGutter) == GutterOptions.None || !this.Visible);
					this.lineNumberWidth = this.lineNumberLength * this.owner.Painter.measureString("9") + this.lineNumbersLeftIndent + this.LineNumbersRightIndent + (flag2 ? 1 : 0);
				}
			}
			return flag;
		}
		private bool AllowOutlining()
		{
			return this.owner != null && this.owner.Outlining.AllowOutlining;
		}
		private Point ScreenToClient(int x, int y)
		{
			return new Point(x, y);
		}
		private void DrawGutter(Painter painter, Rectangle rect, int startLine)
		{
			int num = -1;
			int num2 = -1;
			bool flag = false;
			int num3 = 0;
			this.DrawGutter(painter, rect, false, startLine, 0, ref num3, ref num, ref num2, ref flag);
		}
		private ImageList GetImages(IBookMark bookmark)
		{
			ImageList imageList = this.owner.Source.BookMarks.GetImages(bookmark.Group);
			return (imageList != null) ? imageList : this.Images;
		}
		private void DrawGutter(Painter painter, Rectangle rect, bool calcIndex, int line, int imageX, ref int group, ref int index, ref int imageIndex, ref bool bookMark)
		{
			int num = rect.Top;
			int lineHeight = painter.lineHeight;
			OutlineOptions outlineOptions = this.owner.Outlining.OutlineOptions;
			bool flag = (outlineOptions & OutlineOptions.DrawLines) != OutlineOptions.None;
			bool allowOutlining = this.owner.Outlining.AllowOutlining;
			bool flag2 = (this.options & GutterOptions.PaintLinesBeyondEof) != GutterOptions.None;
			bool flag3 = this.NeedLineNumbers();
			bool flag4 = (this.options & GutterOptions.PaintBookMarks) != GutterOptions.None;
		    bool flag6 = flag3 && (this.visible & (this.options & GutterOptions.PaintLinesOnGutter) != GutterOptions.None);
			bool flag7 = (this.options & GutterOptions.PaintLineModificators) != GutterOptions.None;
			int lineNumbersLeft = this.GetLineNumbersLeft(true);
			int lineNumbersRight = this.GetLineNumbersRight(true);
			int outlineLeft = this.GetOutlineLeft(true);
			int lineModificatorLeft = this.GetLineModificatorLeft();
			int num2 = rect.Left + this.GetPaintWidth(false);
			int num3 = this.GetPaintWidth() - 0;
			int displayCount = this.owner.DisplayLines.DisplayCount;
			IList<IBookMark> list = new List<IBookMark>();
			IList<ILineStyle> list2 = new List<ILineStyle>();
			List<int> list3 = new List<int>();
			List<Gutter.BookMarkImage> list4 = new List<Gutter.BookMarkImage>();
			NavigateOptions navigateOptions = this.owner.NavigateOptions;
			try
			{
				this.owner.SetNavigateOptions(navigateOptions | NavigateOptions.BeyondEof);
				while (num < rect.Bottom || calcIndex)
				{
					Point point = this.owner.DisplayLines.DisplayPointToPoint(0, line);
					if (line >= displayCount && (!flag3 || !flag2))
					{
						break;
					}
					if (flag7 && !calcIndex)
					{
						this.DrawLineModificator(painter, point.Y, lineModificatorLeft, num);
					}
					if (flag3 && !calcIndex)
					{
						if (point.X == 0)
						{
							this.DrawLineNumber(painter, point.Y, lineNumbersLeft, num, flag6);
						}
						else
						{
							if (!this.Transparent)
							{
								Color backColor = painter.BackColor;
								try
								{
									painter.BackColor = (flag6 ? this.BrushColor : this.lineNumbersBackColor);
									painter.FillRectangle(lineNumbersLeft, num, lineNumbersRight - lineNumbersLeft, lineHeight);
								}
								finally
								{
									painter.BackColor = backColor;
								}
							}
						}
					}
					if (line < displayCount)
					{
						if (this.Visible)
						{
							list3.Clear();
							list4.Clear();
							if (this.owner.WordWrap && point.X != 0 && this.wrapImageIndex >= 0)
							{
								if (this.CanDrawImage(this.Images, this.wrapImageIndex))
								{
									list3.Add(this.wrapImageIndex);
								}
							}
							if (flag4)
							{
								Point endPoint = this.owner.DisplayLines.DisplayPointToPoint(int.MaxValue, line, true, false, false);
								this.owner.Source.BookMarks.GetBookMarks(point, endPoint, list);
								foreach (IBookMark current in list)
								{
									if (!this.owner.Outlining.AllowOutlining || this.owner.Outlining.IsVisible(new Point(current.Pos, current.Line)))
									{
										ImageList imageList = this.GetImages(current);
										if (imageList != null)
										{
											int group2 = current.Group;
											int zIndex = current.ZIndex;
											int num4 = current.ImageIndex;
											if (num4 == -1)
											{
												num4 = current.Index;
											}
											if (num4 == int.MaxValue)
											{
												num4 = this.bookMarkImageIndex;
											}
											if (this.CanDrawImage(imageList, num4))
											{
												list4.Add(new Gutter.BookMarkImage(imageList, group2, current.Index, num4, zIndex));
											}
										}
									}
								}
							}
							if (num >= rect.Top - this.Images.ImageSize.Height)
							{
								if (point.X == 0)
								{
									if (!this.owner.Outlining.AllowOutlining || this.owner.Outlining.IsVisible(point.Y))
									{
										this.owner.Source.LineStyles.GetLineStyles(point.Y, list2);
										if (list2.Count > 0)
										{
											for (int i = list2.Count - 1; i >= 0; i--)
											{
												EditLineStyle editLineStyle = this.owner.LineStyles[list2[i].Index];
												if (editLineStyle != null)
												{
													int num4 = editLineStyle.ImageIndex;
													if (this.CanDrawImage(this.Images, num4))
													{
														list3.Add(num4);
													}
												}
											}
										}
									}
								}
							}
							if (list3.Count > 0 || list4.Count > 0)
							{
								if (list4.Count > 0)
								{
									list4.Sort(this.bookmarkComparer);
								}
								int num5 = 0;
								Size imageSize = this.Images.ImageSize;
								Rectangle empty = Rectangle.Empty;
								if (!this.Transparent && imageSize.Width != 0)
								{
									empty = new Rectangle(num5, num, Math.Min((list3.Count + list4.Count > 0) ? 1 : 0, num2 / imageSize.Width) * imageSize.Width, imageSize.Height);
									painter.FillRectangle(empty);
								}
								foreach (Gutter.BookMarkImage current2 in list4)
								{
									if (calcIndex && imageX >= num5 && imageX < num5 + imageSize.Width)
									{
										index = current2.Index;
										imageIndex = current2.ImageIndex;
										group = current2.Group;
										bookMark = true;
									}
									if (!calcIndex)
									{
										this.DrawImage(painter, current2.Images, current2.ImageIndex, point.Y, num5, num, num2, true);
									}
									if (num5 <= num2 - imageSize.Width * 2)
									{
										num5 += imageSize.Width;
									}
								}
								foreach (int current3 in list3)
								{
									if (calcIndex && imageX >= num5 && imageX < num5 + imageSize.Width)
									{
										imageIndex = current3;
										group = 0;
										bookMark = false;
									}
									if (!calcIndex)
									{
										this.DrawImage(painter, this.Images, current3, point.Y, num5, num, num2, false);
									}
									if (num5 <= num2 - imageSize.Width * 2)
									{
										num5 += imageSize.Width;
									}
								}
								if (!calcIndex && !this.Transparent && !empty.IsEmpty)
								{
									painter.ExcludeClipRect(empty.Left, empty.Top, empty.Width, empty.Height);
								}
							}
						}
						if (allowOutlining && !calcIndex)
						{
							this.owner.Outlining.GetOutlineRanges(this.ranges, point.Y);
							DisplayStrings displayLines = this.owner.DisplayLines;
							Point ePt = displayLines.DisplayPointToPoint(int.MaxValue, line, true, false, false);
							bool flag8 = false;
							bool flag9 = true;
							using (IEnumerator<Range> enumerator4 = this.ranges.GetEnumerator())
							{
								while (enumerator4.MoveNext())
								{
									OutlineRange outlineRange = (OutlineRange)enumerator4.Current;
									if (this.CompareRange(outlineRange.StartPoint, point, ePt) == 0)
									{
										flag9 &= outlineRange.Visible;
										flag8 = true;
									}
								}
							}
							if (flag8)
							{
								Range range = this.ranges[0];
								this.DrawOutlineImage(painter, point.Y, outlineLeft, num, lineHeight, flag, flag9, this.CompareRange(range.StartPoint, point, ePt) > 0, this.CompareRange(range.EndPoint, point, ePt) < 0);
							}
							if (!flag8 && flag)
							{
								bool flag10 = false;
								bool flag11 = false;
								using (IEnumerator<Range> enumerator4 = this.ranges.GetEnumerator())
								{
									while (enumerator4.MoveNext())
									{
										OutlineRange outlineRange = (OutlineRange)enumerator4.Current;
										int num6 = this.CompareRange(outlineRange.StartPoint, point, ePt);
										int num7 = this.CompareRange(outlineRange.EndPoint, point, ePt);
										flag10 |= (num6 > 0 && num7 <= 0);
										flag11 |= (num7 == 0);
									}
								}
								if (flag10)
								{
									this.DrawOutline(painter, point.Y, outlineLeft, num, lineHeight, flag11);
								}
							}
						}
					}
					if (calcIndex)
					{
						break;
					}
					num += lineHeight;
					line++;
				}
				if (!calcIndex)
				{
					if (flag3 && !this.Transparent && num > rect.Top && lineNumbersRight > lineNumbersLeft)
					{
						painter.ExcludeClipRect(lineNumbersLeft, rect.Top, lineNumbersRight - lineNumbersLeft, num - rect.Top);
					}
				}
			}
			finally
			{
				this.owner.SetNavigateOptions(navigateOptions);
			}
		}

	    protected bool CanDrawImage(ImageList images, int index, int left, int right)
		{
			return images != null && index >= 0 && index < images.Images.Count && left + images.ImageSize.Width <= right;
		}
		protected bool CanDrawImage(ImageList images, int index)
		{
			return images != null && index >= 0 && index < images.Images.Count;
		}
		protected virtual void OnWidthChanged()
		{
			if (this.visible)
			{
				this.Update();
			}
		}
		protected virtual void OnVisibleChanged()
		{
			if (this.owner != null && this.owner.WordWrap)
			{
				this.owner.UpdateWordWrap();
			}
			this.Update();
		}
		protected virtual void OnShowBookmarkHintsChanged()
		{
		}
		protected virtual void OnDrawLineBookmarksChanged()
		{
			if (this.owner != null)
			{
				this.owner.Invalidate();
			}
		}
		protected virtual void OnLineBookmarksColorChanged()
		{
			if (this.drawLineBookmarks && this.owner != null)
			{
				this.owner.Invalidate();
			}
		}
		protected virtual void OnLineNumbersRightIndentChanged()
		{
			this.InvalidateLineNumberArea(true);
			this.Update();
		}
		protected virtual void OnLineNumbersForeColorChanged()
		{
			this.Update(this.NeedLineNumbers());
		}
		protected virtual void OnLineNumbersBackColorChanged()
		{
			this.Update(this.NeedLineNumbers());
		}
	
	    protected virtual bool IsMouseOnLineModificatorArea(int x, int y)
		{
			bool result;
			if ((this.options & GutterOptions.PaintLineModificators) != GutterOptions.None)
			{
				x = this.ScreenToClient(x, y).X;
				int lineModificatorLeft = this.GetLineModificatorLeft();
				result = (x >= lineModificatorLeft && x <= lineModificatorLeft + this.GetLineModificatorWidth(false));
			}
			else
			{
				result = false;
			}
			return result;
		}
		protected virtual bool IsMouseOnGutterImage(int x, int y, out int group, out int index, out int imageIndex, out bool bookMark)
		{
			imageIndex = -1;
			index = -1;
			bookMark = false;
			group = 0;
			if (this.Visible && this.IsMouseOnGutter(x, y, true))
			{
				x = this.ScreenToClient(x, y).X;
				Point point = this.owner.ScreenToDisplay(x, y);
				Rectangle rect = this.Rect;
				this.DrawGutter(this.owner.Painter, new Rectangle(rect.Left, rect.Top, this.Width, 0), true, point.Y, x, ref group, ref index, ref imageIndex, ref bookMark);
			}
			return imageIndex >= 0;
		}
		protected virtual bool IsMouseOnGutter(int x, int y, bool strictCheck)
		{
			x = this.ScreenToClient(x, y).X;
			return x >= this.Rect.Left && x <= this.Rect.Left + (strictCheck ? this.GetPaintWidth() : this.DisplayWidth);
		}
		protected virtual bool IsMouseOnOutlineArea(int x, int y)
		{
			bool result;
			if (this.AllowOutlining())
			{
				x = this.ScreenToClient(x, y).X;
				int num = this.GetOutlineLeft(false) + this.Rect.Left;
				result = (x >= num && x <= num + this.GetOutlineWidth());
			}
			else
			{
				result = false;
			}
			return result;
		}
		protected virtual bool IsMouseOnOutlineImage(int x, int y, ref Point outPt)
		{
			bool result;
			if (this.AllowOutlining())
			{
				DisplayStrings displayLines = this.owner.DisplayLines;
				outPt = this.owner.ScreenToDisplay(x, y);
				outPt.X = 0;
				int y2 = outPt.Y;
				outPt = displayLines.DisplayPointToPoint(outPt);
				this.owner.Outlining.GetOutlineRanges(this.ranges, outPt.Y);
				Point ePt = displayLines.DisplayPointToPoint(int.MaxValue, y2, true, false, false);
				bool flag = false;
				using (IEnumerator<Range> enumerator = this.ranges.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						OutlineRange outlineRange = (OutlineRange)enumerator.Current;
						if (this.CompareRange(outlineRange.StartPoint, outPt, ePt) == 0)
						{
							flag = true;
							break;
						}
					}
				}
				if (flag)
				{
					int num = this.GetOutlineLeft(true) + this.Rect.Left;
					int lineHeight = this.owner.Painter.lineHeight;
					Point point = this.ScreenToClient(x, y);
					int top = this.Rect.Top;
					int num2 = (lineHeight == 0) ? point.Y : (top + (point.Y - top) / lineHeight * lineHeight);
					int num3 = this.ImageWidth();
					this.CenterOutlineRect(ref num, ref num2, lineHeight);
					result = (point.X >= num - 1 && point.X <= num + num3 + 1 && point.Y >= num2 - 1 && point.Y <= num2 + num3 + 1);
					return result;
				}
			}
			result = false;
			return result;
		}
		protected virtual bool IsMouseOnLineNumberArea(int x, int y)
		{
			bool result;
			if ((this.options & GutterOptions.PaintLineNumbers) != GutterOptions.None)
			{
				x = this.ScreenToClient(x, y).X;
				result = (x >= this.GetLineNumbersLeft(false) && x <= this.GetLineNumbersRight(false));
			}
			else
			{
				result = false;
			}
			return result;
		}
		public virtual bool IsMouseOnOutlineButton(int x, int y, out OutlineRange range)
		{
			range = null;
			bool result;
			if (this.owner != null && this.owner.Outlining.AllowOutlining && (this.owner.Outlining.OutlineOptions & OutlineOptions.DrawButtons) != OutlineOptions.None)
			{
				Rectangle clientRect;
				{
					clientRect = this.owner.ClientRect;
				}
				int displayWidth = this.DisplayWidth;
				clientRect.X += displayWidth;
				clientRect.Width -= displayWidth;
				if (!clientRect.Contains(x, y))
				{
					result = false;
				}
				else
				{
					Point position = this.owner.ScreenToDisplay(x, y);
					position = this.owner.DisplayLines.DisplayPointToPoint(position.X, position.Y, false, true, false);
					range = this.owner.DisplayLines.GetOutlineRange(position);
					result = (range != null && !range.Visible);
				}
			}
			else
			{
				result = false;
			}
			return result;
		}
		
		public virtual void Paint(Painter painter, Rectangle rect, int startLine)
		{
			if (this.NeedPaint(ref rect))
			{
				Color backColor = painter.BackColor;
				try
				{
					if (painter.lineHeight > 0)
					{
						startLine += rect.Top / painter.lineHeight;
					}
					painter.BackColor = ((this.brush is SolidBrush) ? ((SolidBrush)this.brush).Color : EditConsts.DefaultGutterBackColor);
				
					{
						this.DrawGutter(painter, new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height), startLine);
						int num = this.GetPaintWidth() - 0;
						if (this.Visible && num != 0)
						{
							if (!this.Transparent)
							{
								painter.FillRectangle(0, rect.Top, num - (int)this.Pen.Width, rect.Height);
							}
							painter.DrawLine(num - (int)this.Pen.Width, 0, num - (int)this.Pen.Width, rect.Bottom, this.Pen.Color, (int)this.Pen.Width, this.Pen.DashStyle);
						}
					    num = 0;
						if ((this.options & GutterOptions.PaintLineNumbers) != GutterOptions.None && ((this.options & GutterOptions.PaintLinesOnGutter) == GutterOptions.None || !this.Visible))
						{
							int num2 = this.GetLineNumbersLeft(false);
							int lineNumbersRight = this.GetLineNumbersRight(false);
							if (num2 < lineNumbersRight)
							{
								if (!this.Transparent)
								{
									painter.BackColor = this.lineNumbersBackColor;
									painter.FillRectangle(num2, rect.Top, lineNumbersRight - num2 - 1, rect.Height);
								}
								painter.DrawDotLine(lineNumbersRight - 1, 0, lineNumbersRight - 1, rect.Bottom, this.lineNumbersForeColor, (!this.Transparent) ? this.lineNumbersBackColor : Color.Empty);
							}
						}
						if (!this.Transparent)
						{
							if ((this.owner.Outlining.OutlineOptions & OutlineOptions.DrawOnGutter) == OutlineOptions.None || !this.Visible)
							{
								num = this.GetOutlineWidth();
								if (num != 0)
								{
									painter.BackColor = this.owner.SyntaxPaint.GetBackColor(false);
									int num2 = this.GetOutlineLeft(false);
									Rectangle rectangle = (this.owner != null && this.owner.ActiveOutlineRange != null) ? this.GetHighlightOutlineRectangle(num2, num, this.owner.ActiveOutlineRange.StartPoint.Y, this.owner.ActiveOutlineRange.EndPoint.Y) : Rectangle.Empty;
									Rectangle rect2 = new Rectangle(num2, rect.Top, num, rect.Height);
									if (rectangle != Rectangle.Empty)
									{
										IntPtr rgn = painter.SaveClip(rect2);
										try
										{
											painter.ExcludeClipRect(rectangle);
											painter.FillRectangle(rect2);
										}
										finally
										{
											painter.RestoreClip(rgn);
											painter.FillRectangle(this.HighlightOutlineAreaColor, rectangle);
										}
									}
									else
									{
										painter.FillRectangle(rect2);
									}
								}
							}
							num = this.GetLineModificatorWidth(true);
							if (num != 0)
							{
								painter.BackColor = this.owner.SyntaxPaint.GetBackColor(false);
								painter.FillRectangle(this.GetLineModificatorLeft(), rect.Top, num, rect.Height);
							}
						}
					  
					}
				}
				finally
				{
					painter.BackColor = backColor;
				}
			}
		}
		private Rectangle GetHighlightOutlineRectangle(int left, int width, int first, int last)
		{
			Point point = this.owner.TextToScreen(new Point(0, first), false);
			if (point.Y > 0)
			{
				point.Y--;
			}
			point.X = left;
			Point point2;
			if (last == int.MaxValue)
			{
				point2 = new Point(this.owner.ClientRect.Right, this.owner.ClientRect.Bottom);
			}
			else
			{
				point2 = this.owner.TextToScreen(new Point(int.MaxValue, last), true);
				point2.Y += this.owner.Painter.lineHeight;
			}
			point2.Y++;
			point2.X = point.X + width;
			return new Rectangle(point.X, point.Y, point2.X - point.X + 1, point2.Y - point.Y + 1);
		}
		public virtual void GetHitTest(int x, int y, HitTestInfo hitTestInfo)
		{
			if (this.IsMouseOnGutter(x, y, false))
			{
				hitTestInfo.HitTest |= HitTest.Gutter;
			}
			if (this.IsMouseOnOutlineArea(x, y))
			{
				hitTestInfo.HitTest |= HitTest.OutlineArea;
			}
			Point point = new Point(0, 0);
			if (this.IsMouseOnOutlineImage(x, y, ref point))
			{
				hitTestInfo.HitTest |= HitTest.OutlineImage;
				hitTestInfo.OutlineIndex = point.Y;
			}
			OutlineRange outlineRange;
			if (this.IsMouseOnOutlineButton(x, y, out outlineRange))
			{
				hitTestInfo.HitTest |= HitTest.OutlineButton;
				hitTestInfo.OutlineRange = outlineRange;
			}
			if (this.IsMouseOnLineModificatorArea(x, y))
			{
				hitTestInfo.HitTest |= HitTest.LineModificator;
			}
			int group;
			int bookmark;
			int gutterImage;
			bool flag;
			if (this.IsMouseOnGutterImage(x, y, out group, out bookmark, out gutterImage, out flag))
			{
				hitTestInfo.HitTest |= HitTest.GutterImage;
				if (flag)
				{
					hitTestInfo.HitTest |= HitTest.BookMark;
					hitTestInfo.Group = group;
				}
				hitTestInfo.GutterImage = gutterImage;
				hitTestInfo.Bookmark = bookmark;
			}
			if (this.IsMouseOnLineNumberArea(x, y))
			{
				hitTestInfo.HitTest |= HitTest.LineNumber;
			}
		}
	
		public virtual void OnClick(EventArgs e)
		{
			if (this.Click != null)
			{
				this.Click(this, e);
			}
		}
		public virtual void OnDoubleClick(EventArgs e)
		{
			if (this.DoubleClick != null)
			{
				this.DoubleClick(this, e);
			}
		}
	
		public virtual bool InvalidateLineNumberArea(bool updateWidth)
		{
			bool flag = this.NeedLineNumbers();
			if (flag)
			{
				flag = this.UpdateLineNumberLength(updateWidth);
				if (flag)
				{
					if (this.owner != null)
					{
						if (this.owner.WordWrap)
						{
							this.owner.UpdateWordWrap();
						}
						this.owner.Invalidate();
						this.owner.UpdateCaret();
					}
				}
				else
				{
					if ((this.options & GutterOptions.PaintLineNumbers) != GutterOptions.None && ((this.options & GutterOptions.PaintLinesOnGutter) == GutterOptions.None || !this.Visible))
					{
						if (this.owner != null)
						{
							int lineNumbersRight = this.GetLineNumbersRight(false);
							this.owner.Invalidate(new Rectangle(lineNumbersRight - 1, 0, 1, this.owner.ClientHeight));
						}
					}
				}
			}
			return flag;
		}
		protected virtual void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (this.brush != null)
				{
					this.brush.Dispose();
					this.brush = null;
				}
				if (this.pen != null)
				{
					this.pen.Dispose();
					this.pen = null;
				}
				if (this.internalImages != null)
				{
					this.internalImages.Dispose();
					this.internalImages = null;
				}
			}
		}
		public void Dispose()
		{
			this.Dispose(true);
			GC.SuppressFinalize(this);
		}
	}
}
